Skip to content

fix: close P0 sharding holes from the #56 review - #65

Open
renecannao wants to merge 4 commits into
fix/shard-dml-routingfrom
fix/shard-p0-review
Open

fix: close P0 sharding holes from the #56 review#65
renecannao wants to merge 4 commits into
fix/shard-dml-routingfrom
fix/shard-p0-review

Conversation

@renecannao

Copy link
Copy Markdown
Collaborator

Summary

Fixes the silent-wrong bugs called out on #56:

  • Qualified SET t.id = … is treated as a shard-key assignment and moves the row.
  • A move SELECT that finds no rows is a no-op (WHERE 1=0), not an in-place key UPDATE on shard 0.
  • Empty IN (subquery) becomes 0=1 instead of shipping the subquery to every shard.
  • Subquery string values are copied into the arena (no ResultSet UAF).
  • Redistribute clones the AGGREGATE node so the cached logical plan is not mutated / UAF'd.
  • HASH routes integer-looking strings like ints ('3' and 3 land together).
  • Semi-join prune is INNER-only; colocated joins emit LEFT/RIGHT/FULL.
  • Planner-time SELECTs go through TxnRoutingExecutor.

Stacked on #56 (fix/shard-dml-routing).

Test plan

  • ./run_tests --gtest_brief=1 — 1350 passed, 40 skipped
  • Qualified move, no-row move noop, string/int HASH, LEFT JOIN emit, semi-join skip on LEFT

- Detect qualified SET t.id as a shard-key assignment and move the row.
- Do not fall back to in-place UPDATE when a move SELECT finds no rows.
- Empty IN (subquery) rewrites to FALSE instead of per-shard subquery.
- Copy subquery string values into the arena (no ResultSet UAF).
- Do not mutate the cached logical AGGREGATE when redistributing.
- HASH routes integer-looking strings like ints.
- Semi-join prune is INNER only; colocated joins emit LEFT/RIGHT/FULL.
- Planner-time SELECTs go through TxnRoutingExecutor.
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e5f801f1-7f39-4c51-909b-8617e833ef4d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

Add cases for qualified non-key UPDATE, same-value and multi-row moves,
string/int HASH including negatives and leading zeros, empty IN-subquery
DML, string IN-list delete, INSERT...SELECT empty source, unknown-table
SELECT/UPDATE/DELETE, plan-cache COUNT/SUM twice, composite qualified
move, RIGHT JOIN emit, LIST OR prune, and partial vs full composite HASH
prune.
- ResultSet carries ok/error_message so INSERT...SELECT and move SELECTs
  no longer treat a failed remote as zero rows.
- Unknown-table SELECT returns ResultSet::fail instead of {}.
- Shard-key move SELECT uses FOR UPDATE; empty/error does not in-place
  update. Session refuses a DELETE+INSERT move without a distributed txn.
- shard_index_for_* return SIZE_MAX when unroutable; engine_stress uses try_*.
New tests/test_shard_battery.cpp covers HASH/RANGE/LIST/composite routing,
planner prune matrix, INSERT-then-SELECT for ids 0–49, moves, LIST miss,
RANGE placement, and Session COUNT cache hits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant